/*
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef RUNRECORD_H
#define RUNRECORD_H
#include "garmin.h"
#include "lap.h"
#include "track.h"
#include <QtCore>

class RunRecord
{
public:
  RunRecord();
  RunRecord(garmin_data*);
  RunRecord(QString filename);
  QString toString();
  QString toKMLPath();
  void load(char* filename);
  void load(QString filename);
  QDate getDate();
  QTime getTime();
  Track getTrack();

private:
  void initFromData(garmin_list* list);
  QString XMLTag(QString tag, QString text);

  QList<Lap> laps;
  // runrecord has a track
  // runrecord also has laps
  // each of which has a track
  // so 2x memory is used
  // but organization is improved
  // optimize later
  Track track;
  
  uint16  track_index;  // TODO: duplicate to track.index

  uint16  first_lap_index; // first associated lap
  uint16  last_lap_index;  // last associated lap

  // enum {
  // running = 0,
  // biking  = 1,
  // other   = 2
  // }
  uint8   sport_type;

  // bitfield
  // bit;
  // 0 virtual partner run
  // 1 associated with a workout
  // 2 quickworkout
  // 3 associated with a course
  // 4 interval workout
  // 5 part of auto-multisport session
  // 6 undefined. 0
  // 7 undefined. 0
  uint8  program_type;

  // enum {
  // no = 0, // not part of multisport
  // yes = 1, // part of multisport
  // yesAndLastInGroup = 2 // last in session
  // }
  uint8  multisport;

  //TODO: not sure what to do with this...
  struct {
    uint32   time;
    float32  distance;
  } quick_workout;
  D1008    workout;
  

};

#endif // GARMINRUNRECORD_H
